package com.facebook.commands 
{
	import com.facebook.utils.parser.abstract.aParser;
	import com.facebook.Events.FacebookEvent;
	import com.facebook.data.FacebookData;
	import com.facebook.errors.FacebookError;

	import flash.events.EventDispatcher;
	import flash.net.URLVariables;

	/**
	 * @author Ben Smith
	 */

	
	
	public class FacebookCall extends EventDispatcher 
	{

		private var _args : URLVariables;
		private var _method : String;

		private var _result : FacebookData;
		private var _error : FacebookError;
		private var _success : Boolean = false;
		protected var _parser:aParser

		public function FacebookCall()
		{
		}

		public function handleResult(result : FacebookData) : void 
		{
			_result = result;
			_success = true;
		
			dispatchEvent(new FacebookEvent(FacebookEvent.COMPLETE, false, false, true, result));
		}

		public function handleError(error : FacebookError) : void 
		{
			_error = error;
			_success = false;
			dispatchEvent(new FacebookEvent(FacebookEvent.COMPLETE, false, false, false, null, error));
		}

		public function get method() : String {
			return _method;
		}

		public function set method(method : String) : void {
			_method = method;
		}

		public function get error() : FacebookError {
			return _error;
		}

		public function set error(error : FacebookError) : void {
			_error = error;
		}

		public function get success() : Boolean {
			return _success;
		}

		public function set success(success : Boolean) : void {
			_success = success;
		}

		public function get result() : FacebookData {
			return _result;
		}

		public function set result(result : FacebookData) : void {
			_result = result;
		}

		public function get args() : URLVariables {
			return _args;
		}

		public function set args(args : URLVariables) : void {
			_args = args;
		}

		public function makeCall(format : String = "JSON") : FacebookCall
		{
			
			_args.format=format;
			return this
		}

		public function call() : String
		{
			return null
		}

		public function quickTrace() : void
		{
		}
		
		public function get parser() : aParser {
			return _parser;
		}
		
		public function set parser(parser : aParser) : void {
			_parser = parser;
		}
	}
}
